from flask import Flask,render_template
import api.face_api
import core.face_data
import api
from waitress import serve

def create_app():
    # 初始化 Flask 应用
    app = Flask(__name__)
    # app.config.from_object(config_class)
    init_views(app)
    # 注册蓝图
    #app.register_blueprint(api.route.bp) # OCR识别路由
    app.register_blueprint(api.face_api.bp) # 人脸识别路由

    # 加载人脸数据
    core.face_data.init()
    # 初始化线程池
    core.thred_pool.init()
    return app

def init_views(app):
    @app.route('/')
    def index():
        return render_template("index.html")
    @app.route('/face_train')
    def face_train():
        return render_template("face_train.html")
    
if __name__ == '__main__':
    app = create_app()
    #app.run(host='0.0.0.0', port=5000)
    serve(app, host='0.0.0.0', port=5001)



